package com.qf.day12.list;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ArtShowServiceImpl implements ArtShowService{

    private List<ArtShow> data = ArtShowUtils.createList();

    public ArtShowServiceImpl() throws FileNotFoundException {

    }

    @Override
    public boolean addArtShow(String studentName) {

        boolean add = data.add(new ArtShow(studentName, null, 0, 1));
        return add;
    }

    @Override
    public String pickStudent() {
        return null;
    }

    @Override
    public boolean updateArtShow(ArtShow artShow) {
        int index=0;
        for(int i=0;i<data.size();i++){
            if (artShow.getStuName().equals(data.get(i).getStuName())){
                index=i;
            }
        }
        if(index==0){
            return false;
        }else{
            Scanner scanner = new Scanner(System.in);

            System.out.println("请输入才艺名字");
           String showName=scanner.next();
            artShow.setShowName(showName);
            artShow.setCount(0);
            artShow.setStatus(1);
            data.remove(index);
            data.add(index,artShow);
            return true;
        }

    }

    @Override
    public List<ArtShow> getAll(){

        return data;
    }

    @Override
    public List<String> getNoShowNames() {
        List<String>list=new ArrayList<>();
       for(ArtShow artShow:data){
           if(artShow.getCount()!=0){
               list.add(artShow.getStuName());
           }
       }
        return list;
    }
}
